<template>
  <div class="right-chart-2">
    <div class="lc1-header">路段流量排名TOP10</div>
    <div>
      <dv-scroll-board :config="config" class="board-list" />
    </div>
  </div>
</template>

<script>
export default {
  name: 'RightChart2',
  props: {
    selectFlows: {
      type: Array,
      default: () => Array
    }
  },
  data () {
    return {
      config: {
        header: ['路名', '区段', '平均流量'],
        data: [
          ['G92杭向', 'K623', '6.66'],
          ['G92杭向', 'K623', '6.66'],
          ['G92杭向', 'K623', '6.66'],
          ['G92杭向', 'K623', '6.66'],
          ['G92杭向', 'K623', '6.66'],
          ['G92杭向', 'K623', '6.66'],
          ['G92杭向', 'K623', '6.66'],
          ['G92杭向', 'K623', '6.66'],
          ['G92杭向', 'K623', '6.66'],
          ['G92杭向', 'K623', '6.66']
        ],
        rowNum: 5, // 表格行数
        headerHeight: 35,
        headerBGC: 'transparent', // 表头
        oddRowBGC: 'transparent', // 奇数行
        evenRowBGC: 'transparent', // 偶数行
        columnWidth: [100],
        align: ['center']
      }
    }
  },
  created () {
    this.initData()
  },
  watch: {
    selectFlows (newV, oldV) {
      if (newV === null) {
        return
      }
      var result = []
      for (var i = 0; i < newV.length; i++) {
        var temp = []
        temp.push(newV[i].ranking + '')
        temp.push(newV[i].sectionName + '')
        temp.push(newV[i].carFlowNum + '')
        result.push(temp)
      }
      // console.log(result)
      this.initData()
      // console.log(this.config.data)
    }
  },
  methods: {
    initData () {
      // console.log('ss', this.selectSection)
      if (this.selectFlows === null) {
        return
      }
      var result = []
      for (var i = 0; i < this.selectFlows.length; i++) {
        var temp = []
        temp.push(this.selectFlows[i].ranking + '')
        temp.push(this.selectFlows[i].sectionName + '')
        temp.push(this.selectFlows[i].carFlowNum + '')
        result.push(temp)
      }
      // console.log(result)
      this.config = {
        header: ['排名', '路段名', '车流量'],
        data: result,
        rowNum: 5, // 表格行数
        headerHeight: 35,
        headerBGC: 'transparent', // 表头
        oddRowBGC: 'transparent', // 奇数行
        evenRowBGC: '#051fa44C', // 偶数行
        columnWidth: [100, 180, 150],
        align: ['center']
      }
    }
  }
}
</script>

<style lang="less">
.right-chart-2 {
  width: 100%;
  height: 100%;
  display: flex;
  flex-grow: 0;
  flex-direction: column;

  .lc1-header {
    text-align: center;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    color: #fff;
    margin-top: 10px;
  }

  .lc1-details {
    height: 50px;
    font-size: 16px;
    display: flex;
    align-items: center;
    text-indent: 20px;

    span {
      color: #096dd9;
      font-weight: bold;
      font-size: 35px;
      margin-left: 20px;
    }
  }

  .lc1-chart {
    flex: 1;
  }
  .dv-scroll-board .header .header-item {
    color: #fff;
  }
  .dv-scroll-board .header {
    font-size: 20px;
    font-weight: bolder;
  }
  .board-list {
    width: 96%;
    height: 330px;
    margin-left: 6px;
    // background-color: rgba(8,15,31,.3);
  }
}
</style>
